/*======================================================================================

    ichess.h  -  Copyright (C) 1999-2005 by Don Cross

    Win32 version of InternetChessPlayer.
    Allows two instances of Chenard to play chess over TCP/IP using WinSock.

======================================================================================*/
#ifndef __ddc_chenard_ichess_h
#define __ddc_chenard_ichess_h


#define  DEFAULT_CHENARD_PORT   5387


struct InternetConnectionInfo
{
    SOCKET commSocket;
    int waitForClient;
};


class InternetChessPlayer: public ChessPlayer
{
public:
    InternetChessPlayer ( ChessUI &, const InternetConnectionInfo & );
    ~InternetChessPlayer();

    static void      SetServerPortNumber ( unsigned newPortNumber );
    static unsigned  QueryServerPortNumber();

    virtual bool GetMove ( ChessBoard &, Move &, INT32 &timeSpent );
    virtual void InformResignation();
    virtual void InformGameOver ( const ChessBoard & );
    virtual QuitGameReason QueryQuitReason() const { return quitReason; }

protected:
    bool send ( const ChessBoard & );
    bool receive ( ChessBoard &board, Move &move );

private:
    static unsigned ServerPortNumber;

private:
    int isConnected;
    InternetConnectionInfo connectInfo;
    QuitGameReason quitReason;
};


#endif // __ddc_chenard_ichess_h
